Newer
Older
taehui / qwilight-fe / src / app / [language] / note / components / CommentItems.tsx
@Taehui Taehui on 17 Mar 1 KB 2024-03-17 오후 2:12
import CommentItem from "@/app/[language]/note/components/CommentItem";
import { GetCommentAPI } from "@/type/wwwAPI";
import { formatText } from "@/utilities/Utility";

export default function CommentItems({
  comments,
  commentPlace,
  totalCount,
  wantAvatarID,
  wantAvatarName,
}: {
  comments: GetCommentAPI["comments"];
  commentPlace: number;
  totalCount: number;
  wantAvatarID?: string;
  wantAvatarName?: string;
}) {
  return (
    <>
      {commentPlace !== -1 && (
        <>
          <span className="avatarPlace">#{formatText(commentPlace + 1)}</span>
          <span>/{formatText(totalCount)}</span>
        </>
      )}
      {comments.map(
        ({
          date,
          avatarID,
          avatarName,
          stand,
          band,
          point,
          commentary,
          isP,
          judgmentMode,
          hitPointsMode,
          isPaused,
          handled,
        }) => (
          <CommentItem
            key={avatarID}
            date={date}
            avatarID={avatarID}
            avatarName={avatarName}
            stand={stand}
            band={band}
            point={point}
            isP={isP}
            commentary={commentary}
            isTargetAvatar={
              !!(wantAvatarID && wantAvatarID === avatarID) ||
              !!(wantAvatarName && wantAvatarName === avatarName)
            }
            judgmentMode={judgmentMode}
            hitPointsMode={hitPointsMode}
            isPaused={isPaused}
            handled={handled}
          />
        ),
      )}
    </>
  );
}